﻿using ApiDoc.Models;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WQDSkin.Forms.Component;

namespace ApiDoc.Admin.View.Folder
{
    /// <summary>
    /// frmFolderEdit.xaml 的交互逻辑
    /// </summary>
    public partial class frmFolderEdit : BasePage
    {
        private HttpClientApi httpClient;
        private DoType doType;

        public frmFolderEdit()
        {
            InitializeComponent();
        }

        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);

            this.httpClient = new HttpClientApi();
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            this.Contain.GoBack();
        }

        /// <summary>
        /// 保存目录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void btnSave_Click(object sender, RoutedEventArgs e)
        {
            FolderModel folder = (FolderModel)this.DataContext;
            if (this.txtFolderName.Text == "")
            {
                this.txtFolderName.Focus();
                return;
            }

            if (this.txtRoutePath.Text == "")
            {
                this.txtRoutePath.Focus();
                return;
            }

            folder.FolderName = this.txtFolderName.Text;
            folder.RoutePath = this.txtRoutePath.Text;
            FolderModel folder2 = await this.httpClient.FolderSave(folder);
            if (folder2 != null && folder2.SN > 0)
            {
                MessageBox.Show("保存成功"); 
                base.Contain.CallBack(folder2);
               
            }
        }
    }
}
